#region Usings
using System.Linq;

using BK.Model;
using BK.Repositories.Abstract;
#endregion

namespace BK.Repositories.EF
{
    public class BestExpensesFilesRepository : BaseRepository<BestExpensesFile, ImportedFile, BkDataContext>,
        IBestExpensesFilesRepository
    {
        #region IBestExpensesFilesRepository Members
        public BestExpensesFilesRepository(BkDataContext dataContext) : base(dataContext)
        {
        }

        public ImportedFile GetAnotherByExpense(BestExpense expense)
        {
            BestExpensesRepository bestExpensesRepository = new BestExpensesRepository(Context);

            BestExpensesFile result = (from be in bestExpensesRepository.ObjectSet
                                       where be.Date == expense.Date &&
                                             be.Type == expense.Type &&
                                             be.Amount == expense.Amount &&
                                             be.Currency == expense.Currency &&
                                             be.PaymentType == expense.PaymentType &&
                                             be.Category == expense.Category &&
                                             be.Note == expense.Note &&
                                             be.Account == expense.Account &&
                                             be.BestExpensesFile.Id != expense.BestExpensesFile.Id
                                       select be.BestExpensesFile).FirstOrDefault();

            return result;
        }
        #endregion
    }
}